/**
 * 管理员用户管理路由
 * 提供管理员用户管理的相关API端点
 */

const express = require('express');
const router = express.Router();
const { 
  getAllAdminUsers,
  getAdminUserById,
  createAdminUser,
  updateAdminUser,
  deleteAdminUser,
  changeAdminPassword
} = require('../controllers/adminUser.controller');
const { authenticateToken, authorizeAdmin } = require('../../middleware/auth.middleware');
const { validateAdminUser } = require('../middleware/validation.middleware');
const rateLimiter = require('../../middleware/rateLimiter');

// 应用认证和授权中间件到所有路由
router.use(authenticateToken);
router.use(authorizeAdmin);

// 获取所有管理员用户
router.get('/', rateLimiter(), getAllAdminUsers);

// 根据ID获取管理员用户
router.get('/:id', rateLimiter(), getAdminUserById);

// 创建新管理员用户
router.post('/', rateLimiter(), validateAdminUser, createAdminUser);

// 更新管理员用户
router.put('/:id', rateLimiter(), validateAdminUser, updateAdminUser);

// 删除管理员用户
router.delete('/:id', rateLimiter(), deleteAdminUser);

// 修改管理员密码
router.put('/:id/change-password', rateLimiter(), changeAdminPassword);

module.exports = router;